{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>336</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4</td>\n",
       "      <td>189</td>\n",
       "      <td>5</td>\n",
       "      <td>0.026455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11</td>\n",
       "      <td>63</td>\n",
       "      <td>1</td>\n",
       "      <td>0.015873</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>16</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>17</td>\n",
       "      <td>2435</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   uid  click_num  buy_num  buy_click_ratio\n",
       "0    3        336        0         0.000000\n",
       "1    4        189        5         0.026455\n",
       "2   11         63        1         0.015873\n",
       "3   16         31        0         0.000000\n",
       "4   17       2435        0         0.000000"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "df_user=pd.read_csv('./cache/user_table.csv')\n",
    "df_user.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>196016</th>\n",
       "      <td>649941</td>\n",
       "      <td>110</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196017</th>\n",
       "      <td>649942</td>\n",
       "      <td>51</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196019</th>\n",
       "      <td>649959</td>\n",
       "      <td>23</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196022</th>\n",
       "      <td>649981</td>\n",
       "      <td>48</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196024</th>\n",
       "      <td>649987</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           uid  click_num  buy_num  buy_click_ratio\n",
       "196016  649941        110        0              0.0\n",
       "196017  649942         51        0              0.0\n",
       "196019  649959         23        0              0.0\n",
       "196022  649981         48        0              0.0\n",
       "196024  649987         31        0              0.0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_user[df_user['buy_num']==0].tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>196025</th>\n",
       "      <td>649988</td>\n",
       "      <td>182</td>\n",
       "      <td>10</td>\n",
       "      <td>0.054945</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196026</th>\n",
       "      <td>649989</td>\n",
       "      <td>729</td>\n",
       "      <td>2</td>\n",
       "      <td>0.002743</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196027</th>\n",
       "      <td>649990</td>\n",
       "      <td>274</td>\n",
       "      <td>9</td>\n",
       "      <td>0.032847</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196028</th>\n",
       "      <td>649992</td>\n",
       "      <td>131</td>\n",
       "      <td>4</td>\n",
       "      <td>0.030534</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196029</th>\n",
       "      <td>649997</td>\n",
       "      <td>82</td>\n",
       "      <td>12</td>\n",
       "      <td>0.146341</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           uid  click_num  buy_num  buy_click_ratio\n",
       "196025  649988        182       10         0.054945\n",
       "196026  649989        729        2         0.002743\n",
       "196027  649990        274        9         0.032847\n",
       "196028  649992        131        4         0.030534\n",
       "196029  649997         82       12         0.146341"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_user[df_user['buy_num']!=0].tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>196,030.0000</td>\n",
       "      <td>196,030.0000</td>\n",
       "      <td>196,030.0000</td>\n",
       "      <td>196,030.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>325,252.2071</td>\n",
       "      <td>286.5525</td>\n",
       "      <td>2.9486</td>\n",
       "      <td>0.0172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>187,611.4031</td>\n",
       "      <td>438.8775</td>\n",
       "      <td>5.9398</td>\n",
       "      <td>0.0449</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>3.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>162,756.2500</td>\n",
       "      <td>46.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>325,230.0000</td>\n",
       "      <td>136.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0033</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>487,643.2500</td>\n",
       "      <td>346.0000</td>\n",
       "      <td>3.0000</td>\n",
       "      <td>0.0181</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>649,997.0000</td>\n",
       "      <td>10,122.0000</td>\n",
       "      <td>259.0000</td>\n",
       "      <td>1.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               uid    click_num      buy_num  buy_click_ratio\n",
       "count 196,030.0000 196,030.0000 196,030.0000     196,030.0000\n",
       "mean  325,252.2071     286.5525       2.9486           0.0172\n",
       "std   187,611.4031     438.8775       5.9398           0.0449\n",
       "min         3.0000       1.0000       0.0000           0.0000\n",
       "25%   162,756.2500      46.0000       0.0000           0.0000\n",
       "50%   325,230.0000     136.0000       1.0000           0.0033\n",
       "75%   487,643.2500     346.0000       3.0000           0.0181\n",
       "max   649,997.0000  10,122.0000     259.0000           1.0000"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 输出格式设置，保留四位小数\n",
    "pd.options.display.float_format='{:,.4f}'.format\n",
    "df_user.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>17</td>\n",
       "      <td>2435</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600</th>\n",
       "      <td>2013</td>\n",
       "      <td>4936</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>693</th>\n",
       "      <td>2326</td>\n",
       "      <td>3071</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1021</th>\n",
       "      <td>3379</td>\n",
       "      <td>1591</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1081</th>\n",
       "      <td>3583</td>\n",
       "      <td>2590</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3390</th>\n",
       "      <td>11269</td>\n",
       "      <td>2130</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3527</th>\n",
       "      <td>11714</td>\n",
       "      <td>2022</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3759</th>\n",
       "      <td>12456</td>\n",
       "      <td>2236</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3889</th>\n",
       "      <td>12914</td>\n",
       "      <td>1688</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4260</th>\n",
       "      <td>14156</td>\n",
       "      <td>1513</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4612</th>\n",
       "      <td>15343</td>\n",
       "      <td>2075</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5745</th>\n",
       "      <td>18972</td>\n",
       "      <td>2490</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5903</th>\n",
       "      <td>19487</td>\n",
       "      <td>2496</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6246</th>\n",
       "      <td>20628</td>\n",
       "      <td>2107</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6272</th>\n",
       "      <td>20698</td>\n",
       "      <td>1827</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6337</th>\n",
       "      <td>20894</td>\n",
       "      <td>1549</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6672</th>\n",
       "      <td>22136</td>\n",
       "      <td>1772</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7631</th>\n",
       "      <td>25345</td>\n",
       "      <td>2443</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7758</th>\n",
       "      <td>25764</td>\n",
       "      <td>1865</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7766</th>\n",
       "      <td>25789</td>\n",
       "      <td>2437</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8317</th>\n",
       "      <td>27655</td>\n",
       "      <td>3105</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8862</th>\n",
       "      <td>29444</td>\n",
       "      <td>1539</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9154</th>\n",
       "      <td>30419</td>\n",
       "      <td>1639</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9488</th>\n",
       "      <td>31531</td>\n",
       "      <td>4441</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9833</th>\n",
       "      <td>32709</td>\n",
       "      <td>1628</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10044</th>\n",
       "      <td>33417</td>\n",
       "      <td>2472</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10210</th>\n",
       "      <td>33976</td>\n",
       "      <td>1692</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10444</th>\n",
       "      <td>34758</td>\n",
       "      <td>2711</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10625</th>\n",
       "      <td>35374</td>\n",
       "      <td>1645</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11243</th>\n",
       "      <td>37403</td>\n",
       "      <td>2132</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>184733</th>\n",
       "      <td>612785</td>\n",
       "      <td>2514</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>184802</th>\n",
       "      <td>613011</td>\n",
       "      <td>1588</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>185379</th>\n",
       "      <td>615077</td>\n",
       "      <td>1725</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>185403</th>\n",
       "      <td>615140</td>\n",
       "      <td>1996</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>185739</th>\n",
       "      <td>616197</td>\n",
       "      <td>1974</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>186124</th>\n",
       "      <td>617474</td>\n",
       "      <td>2247</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>186338</th>\n",
       "      <td>618179</td>\n",
       "      <td>1932</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>186650</th>\n",
       "      <td>619203</td>\n",
       "      <td>2278</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>186662</th>\n",
       "      <td>619240</td>\n",
       "      <td>1534</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>187104</th>\n",
       "      <td>620746</td>\n",
       "      <td>1503</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>187530</th>\n",
       "      <td>622182</td>\n",
       "      <td>1841</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>187742</th>\n",
       "      <td>622880</td>\n",
       "      <td>1563</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>187963</th>\n",
       "      <td>623552</td>\n",
       "      <td>3061</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>188648</th>\n",
       "      <td>625845</td>\n",
       "      <td>2067</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>188847</th>\n",
       "      <td>626552</td>\n",
       "      <td>2606</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>190868</th>\n",
       "      <td>633206</td>\n",
       "      <td>1567</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>190879</th>\n",
       "      <td>633253</td>\n",
       "      <td>1832</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>191088</th>\n",
       "      <td>633927</td>\n",
       "      <td>1883</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>191499</th>\n",
       "      <td>635316</td>\n",
       "      <td>2792</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>192394</th>\n",
       "      <td>638218</td>\n",
       "      <td>4310</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>192427</th>\n",
       "      <td>638325</td>\n",
       "      <td>1706</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>192678</th>\n",
       "      <td>639188</td>\n",
       "      <td>2826</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>193218</th>\n",
       "      <td>640871</td>\n",
       "      <td>1884</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>193353</th>\n",
       "      <td>641336</td>\n",
       "      <td>2598</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>193753</th>\n",
       "      <td>642676</td>\n",
       "      <td>2146</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194043</th>\n",
       "      <td>643615</td>\n",
       "      <td>2299</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194549</th>\n",
       "      <td>645294</td>\n",
       "      <td>1643</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194718</th>\n",
       "      <td>645831</td>\n",
       "      <td>2796</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194985</th>\n",
       "      <td>646656</td>\n",
       "      <td>5432</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195796</th>\n",
       "      <td>649313</td>\n",
       "      <td>1502</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>546 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           uid  click_num  buy_num  buy_click_ratio\n",
       "4           17       2435        0           0.0000\n",
       "600       2013       4936        0           0.0000\n",
       "693       2326       3071        0           0.0000\n",
       "1021      3379       1591        0           0.0000\n",
       "1081      3583       2590        0           0.0000\n",
       "3390     11269       2130        0           0.0000\n",
       "3527     11714       2022        0           0.0000\n",
       "3759     12456       2236        0           0.0000\n",
       "3889     12914       1688        0           0.0000\n",
       "4260     14156       1513        0           0.0000\n",
       "4612     15343       2075        0           0.0000\n",
       "5745     18972       2490        0           0.0000\n",
       "5903     19487       2496        0           0.0000\n",
       "6246     20628       2107        0           0.0000\n",
       "6272     20698       1827        0           0.0000\n",
       "6337     20894       1549        0           0.0000\n",
       "6672     22136       1772        0           0.0000\n",
       "7631     25345       2443        0           0.0000\n",
       "7758     25764       1865        0           0.0000\n",
       "7766     25789       2437        0           0.0000\n",
       "8317     27655       3105        0           0.0000\n",
       "8862     29444       1539        0           0.0000\n",
       "9154     30419       1639        0           0.0000\n",
       "9488     31531       4441        0           0.0000\n",
       "9833     32709       1628        0           0.0000\n",
       "10044    33417       2472        0           0.0000\n",
       "10210    33976       1692        0           0.0000\n",
       "10444    34758       2711        0           0.0000\n",
       "10625    35374       1645        0           0.0000\n",
       "11243    37403       2132        0           0.0000\n",
       "...        ...        ...      ...              ...\n",
       "184733  612785       2514        0           0.0000\n",
       "184802  613011       1588        0           0.0000\n",
       "185379  615077       1725        0           0.0000\n",
       "185403  615140       1996        0           0.0000\n",
       "185739  616197       1974        0           0.0000\n",
       "186124  617474       2247        0           0.0000\n",
       "186338  618179       1932        0           0.0000\n",
       "186650  619203       2278        0           0.0000\n",
       "186662  619240       1534        0           0.0000\n",
       "187104  620746       1503        0           0.0000\n",
       "187530  622182       1841        0           0.0000\n",
       "187742  622880       1563        0           0.0000\n",
       "187963  623552       3061        0           0.0000\n",
       "188648  625845       2067        0           0.0000\n",
       "188847  626552       2606        0           0.0000\n",
       "190868  633206       1567        0           0.0000\n",
       "190879  633253       1832        0           0.0000\n",
       "191088  633927       1883        0           0.0000\n",
       "191499  635316       2792        0           0.0000\n",
       "192394  638218       4310        0           0.0000\n",
       "192427  638325       1706        0           0.0000\n",
       "192678  639188       2826        0           0.0000\n",
       "193218  640871       1884        0           0.0000\n",
       "193353  641336       2598        0           0.0000\n",
       "193753  642676       2146        0           0.0000\n",
       "194043  643615       2299        0           0.0000\n",
       "194549  645294       1643        0           0.0000\n",
       "194718  645831       2796        0           0.0000\n",
       "194985  646656       5432        0           0.0000\n",
       "195796  649313       1502        0           0.0000\n",
       "\n",
       "[546 rows x 4 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_user[(df_user['buy_num']<1) & (df_user['click_num']>1500)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>brand_id</th>\n",
       "      <th>cat_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>621837</td>\n",
       "      <td>10010304</td>\n",
       "      <td>297</td>\n",
       "      <td>44.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1698431</td>\n",
       "      <td>10012546</td>\n",
       "      <td>271</td>\n",
       "      <td>13.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>653495</td>\n",
       "      <td>10026906</td>\n",
       "      <td>1056</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1426380</td>\n",
       "      <td>10012968</td>\n",
       "      <td>297</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>200496</td>\n",
       "      <td>10004565</td>\n",
       "      <td>1056</td>\n",
       "      <td>16.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    spu_id  brand_id  cat_id  click_num  buy_num  buy_click_ratio\n",
       "0   621837  10010304     297    44.0000   0.0000           0.0000\n",
       "1  1698431  10012546     271    13.0000   0.0000           0.0000\n",
       "2   653495  10026906    1056     1.0000   0.0000           0.0000\n",
       "3  1426380  10012968     297     1.0000   0.0000           0.0000\n",
       "4   200496  10004565    1056    16.0000   0.0000           0.0000"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#同理统计商品信息\n",
    "df_goods=pd.read_csv('goods_table.csv')\n",
    "df_goods.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>621837</td>\n",
       "      <td>44.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1698431</td>\n",
       "      <td>13.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>653495</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1426380</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>200496</td>\n",
       "      <td>16.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    spu_id  click_num  buy_num  buy_click_ratio\n",
       "0   621837    44.0000   0.0000           0.0000\n",
       "1  1698431    13.0000   0.0000           0.0000\n",
       "2   653495     1.0000   0.0000           0.0000\n",
       "3  1426380     1.0000   0.0000           0.0000\n",
       "4   200496    16.0000   0.0000           0.0000"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#针对每一件商品，统计其点击购买\n",
    "df_sp =  df_goods[['spu_id', 'click_num', 'buy_num', 'buy_click_ratio']]\n",
    "df_sp.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1731056</td>\n",
       "      <td>387.0000</td>\n",
       "      <td>3.0000</td>\n",
       "      <td>0.0078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1843018</td>\n",
       "      <td>63.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0159</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>462130</td>\n",
       "      <td>14.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1279048</td>\n",
       "      <td>3.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.3333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>161638</td>\n",
       "      <td>95.0000</td>\n",
       "      <td>2.0000</td>\n",
       "      <td>0.0211</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     spu_id  click_num  buy_num  buy_click_ratio\n",
       "15  1731056   387.0000   3.0000           0.0078\n",
       "22  1843018    63.0000   1.0000           0.0159\n",
       "30   462130    14.0000   1.0000           0.0714\n",
       "31  1279048     3.0000   1.0000           0.3333\n",
       "41   161638    95.0000   2.0000           0.0211"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_sp = df_sp[df_sp['buy_num']>0]#剔除没人买过的商品\n",
    "df_sp.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>234,536.0000</td>\n",
       "      <td>234,536.0000</td>\n",
       "      <td>234,536.0000</td>\n",
       "      <td>234,536.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>1,056,104.1906</td>\n",
       "      <td>108.3979</td>\n",
       "      <td>2.4645</td>\n",
       "      <td>0.0691</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>610,254.0032</td>\n",
       "      <td>207.4349</td>\n",
       "      <td>6.8163</td>\n",
       "      <td>0.1137</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>5.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>527,495.5000</td>\n",
       "      <td>18.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0156</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1,055,871.5000</td>\n",
       "      <td>46.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>1,583,765.2500</td>\n",
       "      <td>113.0000</td>\n",
       "      <td>2.0000</td>\n",
       "      <td>0.0769</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2,114,307.0000</td>\n",
       "      <td>7,705.0000</td>\n",
       "      <td>643.0000</td>\n",
       "      <td>1.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              spu_id    click_num      buy_num  buy_click_ratio\n",
       "count   234,536.0000 234,536.0000 234,536.0000     234,536.0000\n",
       "mean  1,056,104.1906     108.3979       2.4645           0.0691\n",
       "std     610,254.0032     207.4349       6.8163           0.1137\n",
       "min           5.0000       1.0000       1.0000           0.0003\n",
       "25%     527,495.5000      18.0000       1.0000           0.0156\n",
       "50%   1,055,871.5000      46.0000       1.0000           0.0355\n",
       "75%   1,583,765.2500     113.0000       2.0000           0.0769\n",
       "max   2,114,307.0000   7,705.0000     643.0000           1.0000"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_sp.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>90519</th>\n",
       "      <td>1261881</td>\n",
       "      <td>2,858.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>319064</th>\n",
       "      <td>2063191</td>\n",
       "      <td>2,304.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>392885</th>\n",
       "      <td>1976027</td>\n",
       "      <td>2,683.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>461389</th>\n",
       "      <td>1101741</td>\n",
       "      <td>2,110.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>810397</th>\n",
       "      <td>564449</td>\n",
       "      <td>2,261.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>884540</th>\n",
       "      <td>1044530</td>\n",
       "      <td>2,341.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>916625</th>\n",
       "      <td>385994</td>\n",
       "      <td>2,267.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1156468</th>\n",
       "      <td>1733289</td>\n",
       "      <td>2,814.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1179561</th>\n",
       "      <td>2006587</td>\n",
       "      <td>2,046.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1276865</th>\n",
       "      <td>1278883</td>\n",
       "      <td>2,017.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1561137</th>\n",
       "      <td>1600462</td>\n",
       "      <td>2,026.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0005</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          spu_id  click_num  buy_num  buy_click_ratio\n",
       "90519    1261881 2,858.0000   1.0000           0.0003\n",
       "319064   2063191 2,304.0000   1.0000           0.0004\n",
       "392885   1976027 2,683.0000   1.0000           0.0004\n",
       "461389   1101741 2,110.0000   1.0000           0.0005\n",
       "810397    564449 2,261.0000   1.0000           0.0004\n",
       "884540   1044530 2,341.0000   1.0000           0.0004\n",
       "916625    385994 2,267.0000   1.0000           0.0004\n",
       "1156468  1733289 2,814.0000   1.0000           0.0004\n",
       "1179561  2006587 2,046.0000   1.0000           0.0005\n",
       "1276865  1278883 2,017.0000   1.0000           0.0005\n",
       "1561137  1600462 2,026.0000   1.0000           0.0005"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_sp[(df_sp['buy_num']<2) & (df_sp['click_num']>2000)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
